package com.youkeda.DesertCamel.service.impl;

import com.youkeda.DesertCamel.dao.dataobject.MrBookRecord;
import com.youkeda.DesertCamel.model.BookRecord;
import com.youkeda.DesertCamel.model.QueryBusyParam;
import com.youkeda.DesertCamel.model.Result;
import com.youkeda.DesertCamel.service.CheckService;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * checkServiceImpl的注释
 *
 * @author: Awake
 * @date: 2019-08-07 22:42
 **/
public class CheckServiceImpl implements CheckService {
    /**
     * 查询旅游单达到上限的所有日期不能约了
     * （就是当用户点击选择日期时，我们查询已经达到10单的天数，在前端标红来告诉用户那天）
     *
     * @return 返回一系列日期
     */
    @Override
    public Result queryBusyDay() {
        Result result = new Result();

        List<MrBookRecord> mrBookRecords = mrBookRecordMapper.selectAllByUserID(userId);

        if (mrBookRecords.isEmpty()){
            result.setErrorMessage("无预约记录");
            result.setSuccess(false);
            return result;
        }
        List<BookRecord> returnList = new ArrayList<>();

        for (MrBookRecord mrBookRecord : mrBookRecords) {
            BookRecord record = new BookRecord();

            BeanUtils.copyProperties(mrBookRecord, record);
            /*String meetingRoomId = record.getMeetingRoomId();
            String name = mrMeetingRoomMapper.selectMeetingRoomNameByPrimaryKey(meetingRoomId);
            record.setMeetingRoomName(name);*/

            returnList.add(record);
        }
        result.setData(returnList);
        result.setSuccess(true);
        return result;

    }

    /**
     * 查询某一天的单数是否达到上限
     *
     * @param queryBusyParam 用户点击的日期
     * @return 是或否
     */
    @Override
    public boolean checkTodayIsBusy(QueryBusyParam queryBusyParam) {



        return true;
    }
}
